package org.igeek.atomqq.domain;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

import android.content.pm.FeatureInfo;

/**
 * 好友分组
 * @author 作者 E-mail:hangxin1940@gmail.com
 * @version 创建时间：2011-7-29 下午11:57:00
 */
public class FriendCategory  {
	

	
	private int index;

	private String name;

	private List<Friend> friends;

	private boolean newMessage;
	
	
	
	public FriendCategory() {
		
		friends=Collections.synchronizedList(new ArrayList<Friend>());
		newMessage=false;
	}


	
	public int getIndex() {
		return index;
	}

	public void setIndex(int index) {
		this.index = index;
	}
	
	
	public String getName() {
		return name;
	}



	public void setName(String name) {
		this.name = name;
	}


	public boolean hasNewMessage() {
		return newMessage;
	}

	public void setNewMessage(boolean newMessage) {
		this.newMessage = newMessage;
	}

	public void addFriend(Friend friend){
		friends.add(friend);
	}
	
	public Friend getFriend(int index){
		return friends.get(index);
	}
	
	/**
	 * 获取好友个数
	 * @return
	 */
	public int getFriendCount() {
		return friends.size();
	}
	
	/**
	 * 排序
	 */
	public void sort(){
		Collections.sort(friends);
	}
	
	/**
	 * 获得在线好有个数
	 * @return
	 */
	public int getOnlineCount(){
		
		int count=0;
		
		for(Friend friend:friends){
			if(friend.isOnline()==1)
				count++;
			if(friend.hasNewMessage()==1)
				newMessage=true;
		}
		return count;
	}
	
	
	


	
	
}
